package com.wgt.repository;

import com.wgt.domain.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.List;

/**
 * @author wgt
 * @date 2018/1/4
 * @project new-start-blog
 */
@Repository
public interface UserRepository extends JpaRepository<User,Integer>{

    /**
     * 根据姓名进行模糊查询
     * @param name
     * @return
     */
    Page<User> findByNameLike(String name, Pageable page);

    /**
     * 根据用户名获取
     * @param username
     * @return
     */
    User findByUsername(String username);

    /**
     * 根据邮箱进行查询
     * @param email
     * @return
     */
    User findByEmail(String email);

    /**
     * 根据名称列表查询
     * @param usernames
     * @return
     */
    List<User> findByUsernameIn(Collection<String> usernames);
}
